{{include file="public/header.php"/>}}
<style type="text/css">
	.tabs-wrapper .nav .active{
		background: #E9E9E9;
	}
</style>
<link rel="stylesheet" type="text/css" href="./public/uploadify/uploadify.css">
<script type="text/javascript" charset="utf-8" src="./public/ueditor1_4_3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="./public/ueditor1_4_3/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="./public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
	//启动ueditor
    var ue = UE.getEditor('editor');
    /*ue.addListener("ready", function () {
        // editor准备好之后才可以使用
        ue.setContent('123123');
    });*/
</script>
<ol class="breadcrumb">
	<li>
		<span class="glyphicon glyphicon-home"></span>
		<a href="{{U('Cms/Index/welcome')}}">首页</a>
	</li>
	<li>素材管理</li>
</ol>
<div id="page-wrapper">
	<div class="row">
		<div class="col-lg-12">
			<div class="alert alert-success" style="border:solid 1px #27ae60;">
				<strong>注意!</strong>
				随意修改菜单将影响后台功能<br/>
				随意修改菜单将影响后台功能
			</div>
		</div>
	</div>

<!-- 素材管理 -->
<div class="row">
	<div class="col-lg-12">
		<div class="main-box clearfix">
			<div class="row">
				<div class="tabs-wrapper">
					<div class="form-group col-xs-12">
					<ul class="nav">
						<li style="margin-left:5px;" class="<?php if (!$w) {echo 'active';} ?>"><a href="{{U('Wx/Library/index')}}">文字消息</a></li>
						<li class="<?php if ($w == 1) {echo 'active';} ?>"><a href="{{U('Wx/Library/index',array('w'=>1))}}">图文消息</a></li>
						<li class="<?php if ($w == 2) {echo 'active';} ?>"><a href="{{U('Wx/Library/index',array('w'=>2))}}">图片库</a></li>
					</ul>
						
					</div>
					<div class="tab-content">
						<div class="tab-pane fade active in" >
							<div class="form-group col-xs-3">
								<div class="input-group ">
										<a href="">图文消息</a> / 新建图文消息
								</div>
							</div>
							<div class="form-group col-xs-6">
								<form action=""  method="post" enctype="multipart/form-data">
									<div class="table-responsive">
										<div class="form-group">
											<label class="control-label">标题</label>
											<input name="title" type="text" class="form-control" id="">
										</div>
										<div class="form-group">
											<label class="control-label">作者</label>
											<input name="author" type="text" class="form-control">
										</div>
										<div class="form-group">
											<label class="control-label">封面<span>（大图片建议尺寸：900像素 * 500像素）</span></label>
											<input type="file" name="file_upload" id="file_upload" />
											<input type="hidden" name="cover" value="">
											
											<!-- <input type="file" name="cover" value="从图片库选择" id=""> -->
										</div>
										<div class="form-group">
											<label class="control-label">摘要<span>（选填，该摘要只在发送图文消息为单条时显示）</span></label>
											<textarea class="form-control" name="digest" cols="" rows="5" id=""></textarea>
										</div>
										<div class="form-group">
											<label class="control-label">正文<span>（自动保存：2015-07-28 00:44:49）</span></label>
											<div class="form-group">
											    <script id="editor" type="text/plain" style="width:100%;height:300px;"></script> 
											</div>
										</div>
										<div class="form-group">
											<label class="control-label">原文链接<span>（选填）</span></label>
											<input type="text" name="link" class="form-control">
										</div>
										<div class="form-group">
											<input type="submit" class="btn btn-primary" value="保存">
											<input type="reset" class="btn" value="清除">
										</div>
									</div><!-- table-responsive -->
								</form>
							</div><!-- form-group col-xs-12 -->
						</div>
						<div class="tab-pane fade" id="wordimg">
							<input name="img" value="" type="file">
						</div>
						<div class="tab-pane fade" id="img">
							<input onchange="return set_hidden(this,2);" checked='checked' value="" type="text" class="form-control">
						</div>
					</div><!-- tab-content -->
				</div><!-- tabs-wrapper -->
			</div><!-- row -->
		</div><!-- main-box clearfix -->
	</div><!-- col-lg-12 -->
</div><!-- row -->

<!-- 素材管理 -->

</div>

{{include file="public/footer.php"/}}
<script type="text/javascript" src="./public/js/jquery.form.js"></script>
<script type="text/javascript">
	function ajax_submit()
	{
		var queryString = $('#myForm').formSerialize();

			// 现在可以使用$.get、$.post、$.ajax等来提交数据
			$.post("{{U('wx/library/storeWordImg')}}", queryString);
		return false;
	}

	function doSave(){
    var options = {
            type : 'post',
            data : $('#myForm').serialize(),
            dataType : 'json',
            url : "{{U('wx/library/storeWordImg')}}"
        };
        $(this).ajaxSubmit(options);
        return false;
	}
</script>
    <script type="text/javascript" src="./public/uploadify/jquery.uploadify.min.js"></script>
    <script type="text/javascript">
    $(function() {
        $('#file_upload').uploadify({
            'swf'      : './public/uploadify/uploadify.swf',
	        'buttonClass' : 'color:red',
	        'buttonText' : '添加图片',
	        'uploadLimit' : 8,
            'uploader' : "?m=wx&c=library&a=uploadify",
            'onUploadSuccess': function(file,data,respone)
	        {
	        	var obj = JSON.parse(data);
	        	alert(obj.status);
	        	alert(obj.finalpath);
	        	alert(obj.media_id);
	        	if(obj.status)
	        	{
		            var m = "<img style='width:100px;height:100px;' src=" + obj.finalpath + ">";
		            $("#file_upload").after(m);
		            $("input[name='cover']").val(data.media_id);
	        		
	        	}
	        }
        });
    });
    </script>